package com.sen.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sen.dao.WarehouseLogDao;
import com.sen.dao.WarehouseLogHeadDao;
import com.sen.entity.WarehouseLog;
import com.sen.entity.WarehouseLogHead;
import com.sen.service.WarehouseLogHeadService;
import com.sen.service.WarehouseLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("warehouseLogHeadService")
public class WarehouseLogHeadServiceImpl extends ServiceImpl<WarehouseLogHeadDao, WarehouseLogHead> implements WarehouseLogHeadService {

    @Autowired
    WarehouseLogHeadDao warehouseLogHeadDao;
    @Override
    public IPage<WarehouseLogHead> queryAll(Page<WarehouseLogHead> page, Map<String, String> warehouse) {
        QueryWrapper<WarehouseLogHead> wrapper = new QueryWrapper<>();
        if (warehouse.get("mname")!=null){
            wrapper.like("mname", warehouse.get("mname"));
        }
        if (warehouse.get("createdate[0]")!=null){
            wrapper.between("DATE_FORMAT(wlh.createdate,'%Y-%m-%d')", warehouse.get("createdate[0]"),warehouse.get("createdate[1]"));
        }
        wrapper.orderByDesc("wlh.createdate");
        return  warehouseLogHeadDao.queryAll(page, wrapper);
    }
}
